const Mock = require("mockjs")



function getData(dataTemplate,count){
    let list = []
    for(var i=0;i<count;i++){
        var data =  Mock.mock(dataTemplate)
        list.push(data)
    }

    return list
}

var userInfo = {
    'id': '@id',
    'username': "@cname",
    "age|18-50": 0,
    "phone": "@phone",
    'date': "@date(yyyy-MM-dd hh:mm:ss)",
    "des": "@cparagraph",
    "email": "@email()"
}


var list = getData(userInfo,4)



module.exports= function (app) {
    app.use("/api/userinfo", ((req, res) => {
        //将模拟的数据转为json数据格式
        res.json(list)
    }))
}